<?php

namespace Addons\Cxcj\Controller;

use Home\Controller\AddonsController;
use Org\Util\Snoopy;

class CxcjController extends AddonsController
{
    public function index()
    {
        $userinfo = M("userinfo");
        $ret = $userinfo->where($this->get_param)->find();
        if ($ret > 0) {
            $xh = $ret["xh"];
            session("xh", $xh);
        } else {
            $this->error("还未绑定账号", addons_url("Bdjw://Bdjw/index"));
        }

        $post["token"] = "wxfwh";
        $post["wxopenid"] = get_openid();
        $post["xh"] = $xh;
        session("post",$post);
        $this->assign("xh",$xh);
        $this->display();
}


    public function kscj()
    {

        $post=session("post");
//        $post["xh"]="2014404146";
        $sn = new Snoopy();
        $url = "http://lvc.gxsdxy.cn/api/JwXSCJ/xscjd01";
        $sn->submit($url, $post);
        $cj = json_decode($sn->results, true);
        foreach ($cj["rows"] as $vo) {
            $xqtmp[] = $vo["xnxqh"];
        }
        $xq = array_unique($xqtmp);

        $this->assign("cj", $cj["rows"])->assign("xq", $xq)->assign("json_xq", json_encode($xq));
        $this->display();
    }

    public function kjcj()
    {
        $post = session("post");
//        $post["xh"]="2014404146";
        $sn = new Snoopy();
        $url = "http://lvc.gxsdxy.cn/api/JwKJBM/kjbm01";
        $sn->submit($url, $post);
        $kj = json_decode($sn->results, true);
        $this->assign("kj", $kj["rows"])->assign("time",time());
        $this->display();
    }
}
